const mongoose = require("mongoose")

// 连接数据库
const DB_URL = "mongodb://localhost:27017/heathapp"
mongoose.connect(DB_URL,{ useNewUrlParser: true })
mongoose.connection.on("connected",function(){
    console.log('mongod connect success')
})
// 新建数据库模型
const models = {
	users:{
		'name':{type:String, 'require':true},
		'pass':{type:String, 'require':true},
		'nickName':{type:String, 'require':true},
	}
	
}
for(let m in models){
    mongoose.model(m, new mongoose.Schema(models[m]))
}
module.exports = {
	getModel:function(name){
		return mongoose.model(name)
	}
}
